package com.hzncc.flowable_diboot.project_contracts.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diboot.core.binding.QueryBuilder;
import com.diboot.core.controller.BaseCrudRestController;
import com.diboot.core.vo.JsonResult;
import com.diboot.core.vo.Pagination;
import com.hzncc.flowable_diboot.project_contracts.dto.ProjectContractAuditDTO;
import com.hzncc.flowable_diboot.project_contracts.entity.ProjectContractAudit;
import com.hzncc.flowable_diboot.project_contracts.service.ProjectContractAuditService;
import com.hzncc.flowable_diboot.project_contracts.vo.OldReceivablesVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/old-receivable")
public class oldReceivableController extends BaseCrudRestController<ProjectContractAudit> {

    @Autowired
    private ProjectContractAuditService projectContractAuditService;

    /**
     * 老应收列表查询
     *
     * @param queryDTO
     * @param pagination
     * @return
     * @author 陈广煜
     * @date 2025-03-15
     */
    @GetMapping("")
    public JsonResult<List<OldReceivablesVO>> getOldReceivables(ProjectContractAuditDTO queryDTO, Pagination pagination) {
        QueryWrapper<ProjectContractAudit> queryWrapper = QueryBuilder.toQueryWrapper(queryDTO);
        queryWrapper.eq("cate",2); // 老应收
        List<OldReceivablesVO> viewObjectList = projectContractAuditService.getViewObjectList(queryWrapper, pagination, OldReceivablesVO.class);
        return JsonResult.OK(viewObjectList).bindPagination(pagination);
    }
}
